import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../helper/cacheHelper.dart';
import '../../model/inventory.dart';
import '../../pages/things/things_helper.dart';

import '../../helper/routeHelper.dart';
import '../../helper/uidata.dart';
import '../../model/things.dart';

import '../../widgets/inputWidget.dart';
import '../../widgets/signatureCard2.dart';

import '../../helper/Helper.dart';

class InventoryNotQMPage extends StatefulWidget {
  InventoryNotQMPage();
  @override
  InventoryNotQMPageState createState() => new InventoryNotQMPageState();
}

class InventoryNotQMPageState extends State<InventoryNotQMPage> {
  final String now = Helper.DateTimeNowString();

  bool ifLoad = false;

  late List<Inventory> RList;

  @override
  void initState() {
    super.initState();
    loadData();
  }

  loadData() async {
    var list1 = await Inventory.GetListNotQM();
    RList = list1;

    setState(() {
      ifLoad = true;
    });
  }

  double getTotal() {
    double x1 = 0;
    for (var a in RList) {
      x1 += a.Amount2;
    }
    return x1;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text("未审核单列表"),
      ),

      body: ifLoad
          ? CleanInfoBody(context)
          : Center(
              child: SpinKitCircle(
              color: Colors.blue,
            )),
    );
  }

  CleanInfoBody(BuildContext context) => SingleChildScrollView(
        child: CleanInfoFields(context),
      );

  List<Widget> getWidgetList(BuildContext context) {
    List<Widget> list1 = <Widget>[];
    List<Widget> list3 = <Widget>[];
    List<Widget> list4 = <Widget>[];
    List<Widget> list2 = <Widget>[];

    for (var a in RList) {
      list4.add(ThingsHelper.InventoryCard(context, a, () => {}));
      list4.add(InputWidget.getDivider());
    }

    list1.add(InputWidget.inCard2(list4));

    return list1;
  }

  CleanInfoFields(BuildContext context) => Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: getWidgetList(context),
        ),
      );
}
